package com.xypower.threadTest;

import java.util.concurrent.*;


/**
 * 【阿里巴巴java开发手册】该规范指出在Java编程中，不允许使用Executors去创建线程池，而是通过ThreadPoolExecutor的方式。这样的处理方式可以明确线程池的运行规则，规避资源耗尽的风险。
 */
public class ThreadPoolExecutorTest {
    public static void main(String[] args) {
        LinkedBlockingQueue linkedBlockThreadFactory = new LinkedBlockingQueue();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(3,6,10, TimeUnit.SECONDS,linkedBlockThreadFactory);

        System.out.println("线程池的核心线程数"+threadPoolExecutor.getActiveCount());
        System.out.println("线程池的最大线程数"+threadPoolExecutor.getMaximumPoolSize());
        System.out.println("线程池的超时时间"+threadPoolExecutor.getKeepAliveTime(TimeUnit.SECONDS));

    }
}
